#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 6e4 + 10;
const int S = (1 << 16) + 20;

int f[N][9],n,s[N],k;

struct data {
	int v[S];
	data() { memset(v,0x3f,sizeof v); }
	void insert(int x,int val) {
		int hi = x >> 8 << 8,lo = x ^ hi;
		for(int i = 0;i < 1 << 8;i++) v[i | hi] = min(v[i | hi],(lo ^ i) + val);
	}
	int query(int x) {
		int hi = x >> 8 << 8,lo = x ^ hi,res = 2e9;
		for(int i = 0;i < 1 << 8;i++) res = min(res,v[i << 8 | lo] + (i << 8 ^ hi));
		return res;
	}
} d[9];
	
int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
 	n = in; k = in; for(int i = 1;i <= n;i++) s[i] = s[i - 1] ^ in;
	memset(f,0x3f,sizeof f); f[0][0] = 0; d[0].insert(0,0);
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= k && j <= i;j++) {
			f[i][j] = d[j - 1].query(s[i]);
		}
		for(int j = 1;j < k && j <= i;j++) d[j].insert(s[i],f[i][j]);
	}
	for(int i = k;i <= n;i++) printf("%d%c",f[i][k]," \n"[i == n]);
	return 0;
}
